from django.db import models
# 地址信息
# Create your models here.
from django.utils import timezone
from application.user.models import User


class Address(models.Model):
    del_info = (
        (0, '正常'),
        (1, '删除')
    )
    country_id = models.IntegerField(default=None, verbose_name='国')
    province_id = models.IntegerField(default=None, verbose_name='省')
    city_id = models.IntegerField(default=None, verbose_name='市')
    area_id = models.IntegerField(default=None, verbose_name='区')
    content = models.CharField(max_length=100, verbose_name='详细地址')
    create_time = models.DateTimeField(default=timezone.now, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    del_type = models.IntegerField(choices=del_info, default=0, verbose_name='删除状态')
    user = models.ForeignKey(User, on_delete=models.CASCADE)  # 链接user模型 并做级联


class Map(models.Model):
    """ 地址信息 """
    level_list = (
        (0, '国家'),
        (1, '省份'),
        (2, '；地级市'),
        (3, '县区')
    )
    name = models.CharField(max_length=64, null=False)
    parent_id = models.IntegerField(null=False, default=0, verbose_name='父级地区编码')
    level = models.IntegerField(choices=level_list, default=0, verbose_name='等级')
    short = models.CharField(max_length=10, verbose_name='简称')
    city_code = models.CharField(max_length=10, verbose_name='城市id编号')
    zip_code = models.CharField(max_length=10, verbose_name='邮政编号')
    gcj02_lng = models.CharField(max_length=24, verbose_name='纬度')
    gcj02_lat = models.CharField(max_length=24, verbose_name='经度')
    db09_lng = models.CharField(max_length=64, verbose_name='纬度')
    db09_lat = models.CharField(max_length=64, verbose_name='经度')
    remark1 = models.CharField(max_length=64, verbose_name='备注1')
    remark2 = models.CharField(max_length=64, verbose_name='备注2')

